# -*- coding: utf-8 -*-
import scrapy
from ..items import QuotesItem


class ToscrapeCssSpider(scrapy.Spider):
    name = 'toscrape-css'
    # allowed_domains = ['quotes.toscrape.com/']
    start_urls = ['http://quotes.toscrape.com//']

    def parse(self, response):
        items = []
        for quote in response.css("div.quote"):
            item = QuotesItem()
            item["text"] = quote.css("span.text::text").extract_first()
            item["author"] = quote.css("small.author::text").extract_first()
            item["tags"] = quote.css("div.tags>a.tag::text").extract()
            items.append(item)
        return items
        pass
